/**
 *  污染源数据造假识别-仪表盘
 *  Created by dinghh on 2018/7/13.
 */
'use strict';
angular.module("MetronicApp").directive('counterfeitIndex', function () {
    return {
        scope: {
            id: "@",
            legend: "=",
            data: "=",
            title: "=",
            sameColor: "="
        },
        restrict: 'EA',
        template: '<div style="height:270px;width:270px;margin: 0 auto;"></div>',
        replace: true,
        link: function ($scope, element, attrs, controller) {
            function getOption(data) {
                var option = {
                    series: [
                        {
                            name: '业务指标',
                            type: 'gauge',
                            detail: {
                                formatter:'{value}',
                                textStyle: { // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                                fontSize: 14}
                                },
                            data: [{value: 50}],
                            axisLine:{
                                lineStyle:{
                                    color:[[0.2,'#cc0000'],[0.6,'#f1c232'],[0.9,'#0000ff'],[1,'#274e13']],
                                    width: 20
                                }
                            }
                        }
                    ]
                };
                return option;
            }

            $scope.$watch('data', function (newVal, oldVal) {
                var myChart = echarts.init(document.getElementById($scope.id), 'macarons');
                myChart.showLoading();
                myChart.setOption(getOption(newVal));
                myChart.hideLoading();
            });
        }
    };
});
